package com.ruoyi.school.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.school.domain.Employment;
import com.ruoyi.school.service.IEmploymentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 就业和薪资Controller
 * 
 * @author admin
 * @date 2023-09-03
 */
@RestController
@RequestMapping("/school/employment")
public class EmploymentController extends BaseController
{
    @Autowired
    private IEmploymentService employmentService;

    /**
     * 查询就业和薪资列表
     */
    @PreAuthorize("@ss.hasPermi('school:employment:list')")
    @GetMapping("/list")
    public TableDataInfo list(Employment employment)
    {
        startPage();
        List<Employment> list = employmentService.selectEmploymentList(employment);
        return getDataTable(list);
    }


    /**
     * 导出就业和薪资列表
     */
    @PreAuthorize("@ss.hasPermi('school:employment:export')")
    @Log(title = "就业和薪资", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Employment employment)
    {
        List<Employment> list = employmentService.selectEmploymentList(employment);
        ExcelUtil<Employment> util = new ExcelUtil<Employment>(Employment.class);
        util.exportExcel(response, list, "就业和薪资数据");
    }

    /**
     * 获取就业和薪资详细信息
     */
    @PreAuthorize("@ss.hasPermi('school:employment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(employmentService.selectEmploymentById(id));
    }

    /**
     * 新增就业和薪资
     */
    @PreAuthorize("@ss.hasPermi('school:employment:add')")
    @Log(title = "就业和薪资", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Employment employment)
    {
        return toAjax(employmentService.insertEmployment(employment));
    }

    /**
     * 修改就业和薪资
     */
    @PreAuthorize("@ss.hasPermi('school:employment:edit')")
    @Log(title = "就业和薪资", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Employment employment)
    {
        return toAjax(employmentService.updateEmployment(employment));
    }

    /**
     * 删除就业和薪资
     */
    @PreAuthorize("@ss.hasPermi('school:employment:remove')")
    @Log(title = "就业和薪资", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(employmentService.deleteEmploymentByIds(ids));
    }
}
